﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sinacor.Process.Bovespa.Alocacao.Server.ProcessLogic.Translator.LayoutToProcessEntity
{
    public class Alocacao
    {
        public ProcessEntity.ErroAlocacaoHeader ToErroAlocacaoHeader(Layout.ErroAlocacaoHeader from)
        {
            ProcessEntity.ErroAlocacaoHeader to = null;

            if (from != null)
            {
                to = new ProcessEntity.ErroAlocacaoHeader();

                to.CodigoArquivo = from.CodigoArquivo;
                to.CodigoDestino = from.CodigoDestino;
                to.CodigoOrigem = from.CodigoOrigem;
                to.CodigoUsuario = from.CodigoUsuario;
                to.DataGeracaoArquivo = from.DataGeracaoArquivo;
                to.DataPregao = from.DataPregao;
                to.Erro01 = from.Erro01;
                to.Erro02 = from.Erro02;
                to.Erro03 = from.Erro03;
                to.Reserva = from.Reserva;
                to.TipoRegistro = from.TipoRegistro;
            }

            return to;
        }

        public List<ProcessEntity.ErroAlocacaoHeader> ToErroAlocacaoHeader(List<Layout.ErroAlocacaoHeader> from)
        {
            List<ProcessEntity.ErroAlocacaoHeader> to = null;

            if (from != null)
            {
                to = new List<ProcessEntity.ErroAlocacaoHeader>();

                foreach (Layout.ErroAlocacaoHeader item in from)
                {
                    to.Add(ToErroAlocacaoHeader(item));
                }
            }

            return to;
        }

        public ProcessEntity.ErroAlocacaoDetail ToErroAlocacaoDetail(Layout.ErroAlocacaoDetail from)
        {
            ProcessEntity.ErroAlocacaoDetail to = null;

            if (from != null)
            {
                to = new ProcessEntity.ErroAlocacaoDetail();

                to.CodigoCarteira = from.CodigoCarteira;
                to.CodigoCliente = from.CodigoCliente;
                to.CodigoClienteCorretora = from.CodigoClienteCorretora;
                to.CodigoNegociacao = from.CodigoNegociacao;
                to.CodigoUsuarioCorretora = from.CodigoUsuarioCorretora;
                to.DataPregao = from.DataPregao;
                to.DigitoCliente = from.DigitoCliente;
                to.DigitoClienteCorretora = from.DigitoClienteCorretora;
                to.DigitoCodigoCarteira = from.DigitoCodigoCarteira;
                to.Erro01 = from.Erro01;
                to.Erro02 = from.Erro02;
                to.Erro03 = from.Erro03;
                to.IndicadorEspecificacao = from.IndicadorEspecificacao;
                to.LiquidacaoTermo = from.LiquidacaoTermo;
                to.NaturezaOperacao = from.NaturezaOperacao;
                to.NumeroNegocio = from.NumeroNegocio;
                to.Quantidade = from.Quantidade;
                to.Reserva = from.Reserva;
                to.Reservado = from.Reservado;
                to.TipoRegistro = from.TipoRegistro;
            }

            return to;
        }

        public List<ProcessEntity.ErroAlocacaoDetail> ToErroAlocacaoDetail(List<Layout.ErroAlocacaoDetail> from)
        {
            List<ProcessEntity.ErroAlocacaoDetail> to = null;

            if (from != null)
            {
                to = new List<ProcessEntity.ErroAlocacaoDetail>();

                foreach (Layout.ErroAlocacaoDetail item in from)
                {
                    to.Add(ToErroAlocacaoDetail(item));
                }
            }

            return to;
        }

        public ProcessEntity.ErroAlocacaoTrailer ToErroAlocacaoTrailer(Layout.ErroAlocacaoTrailer from)
        {
            ProcessEntity.ErroAlocacaoTrailer to = null;

            if (from != null)
            {
                to = new ProcessEntity.ErroAlocacaoTrailer();

                to.CodigoArquivo = from.CodigoArquivo;
                to.CodigoDestino = from.CodigoDestino;
                to.CodigoOrigem = from.CodigoOrigem;
                to.CodigoUsuario = from.CodigoUsuario;
                to.DataGeracaoArquivo = from.DataGeracaoArquivo;
                to.Erro01 = from.Erro01;
                to.Erro02 = from.Erro02;
                to.Erro03 = from.Erro03;
                to.Reserva = from.Reserva;
                to.TipoRegistro = from.TipoRegistro;
                to.TotalRegistros = from.TotalRegistros;
            }

            return to;
        }

        public List<ProcessEntity.ErroAlocacaoTrailer> ToErroAlocacaoTrailer(List<Layout.ErroAlocacaoTrailer> from)
        {
            List<ProcessEntity.ErroAlocacaoTrailer> to = null;

            if (from != null)
            {
                to = new List<ProcessEntity.ErroAlocacaoTrailer>();

                foreach (Layout.ErroAlocacaoTrailer item in from)
                {
                    to.Add(ToErroAlocacaoTrailer(item));
                }
            }

            return to;
        }
    }
}
